﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace mitasoft.AdsShedule.Common
{
    public static class XMLUtil
    {
        public static void Serialize<T>(string filePath, T data)
        {
            using (StreamWriter writer = new StreamWriter(filePath))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(T));
                serializer.Serialize(writer, data);
            }
        }

        public static T Deserialize<T>(string filePath)
        {
            using (StreamReader reader = new StreamReader(filePath))
            {
                XmlSerializer deSerializer = new XmlSerializer(typeof(T));
                return (T)deSerializer.Deserialize(reader);
            }
        }
    }
}
